package util;

import builder.MetricBuilder;
import interfaces.ExpectResponse;
import interfaces.HttpClient;
import interfaces.HttpClientImpl;
import response.Response;

import java.io.IOException;

public class OpentsUtil {
    public static void opentsPut(String metricName, long value, String name) {
        HttpClient client = new HttpClientImpl(PropertiesUtils.getProperty("opentsdb"));
        MetricBuilder builder = MetricBuilder.getInstance();

        builder.addMetric(metricName).setDataPoint(value).addTag("dim", name);
        try {
            Response response = client.pushMetrics(builder,
                    ExpectResponse.SUMMARY);
            System.out.println(response);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
